﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.AutoMap;
using FluentNHibernate.AutoMap.Alterations;
using Webshop20.Domain.Catalog.Core;
using FluentNHibernate;

namespace Webshop20.Infrastructure.Persistence.NH.AutoMappings.Overrides
{
    public class VisitorOverride : IAutoMappingOverride<Visitor>
    {
        //public void Override(AutoMap<Visitor> mapping)
        //{
           
        //    //mapping.WithTable("Customer");
        //    mapping.Id(visitor => visitor.Id).GeneratedBy.Assigned();
        //    mapping.Map(x => x.GlobalId);
        //    mapping.HasMany(v => v.LastVisitedItems);
        //    mapping.References(x => x.Cart).Cascade.All();

        //    mapping.IgnoreProperty(x => x.FirstName);
        //    mapping.IgnoreProperty(x => x.LastName);
        //    mapping.IgnoreProperty(x => x.EMail);

        //    //mapping.Map(c => c.FirstName, "FirstName");
        //    //mapping.Map(c => c.LastName, "LastName");
        //    //mapping.Map(c => c.EMail, "EMail");

        //    //mapping.WithTable("Customers", customer =>
        //    //                                  {
        //    //                                        customer.WithKeyColumn("Id"); 	
        //    //                                        customer.Map(c=>c.FirstName);
        //    //                                        customer.Map(c=>c.LastName);
        //    //                                        customer.Map(c=>c.EMail);
        //    //                                  });

        //}

        public void Override(AutoMap<Visitor> mapping)
        {
            mapping.WithTable("Customers");
            mapping.Id(visitor => visitor.Id).GeneratedBy.Assigned();
            mapping.Map(x => x.GlobalId);
            mapping.HasMany(v => v.LastVisitedItems);
            mapping.References(s => s.Cart);



            mapping.Map(c => c.FirstName, "FirstName");
            mapping.Map(c => c.LastName, "LastName");
            mapping.Map(c => c.EMail, "EMail");



        }

        //public void Override(AutoMap<Visitor> mapping)
        //{
        //    mapping.Id(visitor => visitor.Id).GeneratedBy.Assigned();
        //    mapping.Map(x => x.GlobalId);
        //    mapping.HasMany(v => v.LastVisitedItems);
        //    mapping.References(c => c.Cart);
        //    mapping.IgnoreProperty(x => x.FirstName);
        //    mapping.IgnoreProperty(x => x.LastName);
        //    mapping.IgnoreProperty(x => x.EMail);

        //    mapping.WithTable("Customers", customer =>
        //                                      {
        //                                          customer.WithKeyColumn("Id");
        //                                          customer.Map(c => c.FirstName);
        //                                          customer.Map(c => c.LastName);
        //                                          customer.Map(c => c.EMail);
        //                                      });

        //}

    }
}